package com.xoa.controller.party;


import com.xoa.model.party.PropagatePosition;
import com.xoa.service.party.PropagatePositionService;
import com.xoa.util.CookiesUtil;
import com.xoa.util.ToJson;
import com.xoa.util.common.session.SessionUtils;
import com.xoa.util.dataSource.ContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

/**
 * 宣传阵地接口
 * Created by 刘新婷 on 2018-01-16.
 */
@Controller
@RequestMapping("/position")
public class PropagatePositionController {

    @Resource
    PropagatePositionService propagatePositionService;

    //宣传阵地页面映射
    @RequestMapping("/managerIndex")
    public String managerIndex(HttpServletRequest request) {
        Cookie redisSessionCookie = CookiesUtil.getCookieByName(request, "redisSessionId");
        String loginDateSouse = SessionUtils.getSessionInfo(request.getSession(), "loginDateSouse", String.class, redisSessionCookie);
        ContextHolder.setConsumerType("xoa" + loginDateSouse);
        return "app/party/propagatePosition/managerIndex";
    }

    //组织机构宣传阵地页面映射
    @RequestMapping("/managerIndex1")
    public String managerIndex1(HttpServletRequest request) {
        Cookie redisSessionCookie = CookiesUtil.getCookieByName(request, "redisSessionId");
        String loginDateSouse = SessionUtils.getSessionInfo(request.getSession(), "loginDateSouse", String.class, redisSessionCookie);
        ContextHolder.setConsumerType("xoa" + loginDateSouse);
        return "app/party/propagatePosition/managerIndex1";
    }

    //新增活动
    @ResponseBody
    @RequestMapping("/addActivity")
    public ToJson<PropagatePosition> addActivity(PropagatePosition record, String gridLocation){
        return propagatePositionService.addActivity(record,gridLocation);
    }

    //查询宣传阵地活动列表
    @ResponseBody
    @RequestMapping("/getActivityList")
    public ToJson<PropagatePosition> getActivityList(PropagatePosition record, Integer page, Integer pageSize, boolean useFlag){
        return propagatePositionService.getActivityList(record, page, pageSize, useFlag);
    }
    //查询宣传阵地活动列表分组
    @ResponseBody
    @RequestMapping("/getActivityListGroup")
    public ToJson<PropagatePosition> getActivityListGroup(PropagatePosition record, Integer page, Integer pageSize, boolean useFlag){
        return propagatePositionService.getActivityListGroup(record, page, pageSize, useFlag);
    }
    //查询宣传阵地活动详情
    @ResponseBody
    @RequestMapping("/getActivityById")
    public ToJson<PropagatePosition> getActivityById(Integer pId){
        return propagatePositionService.getActivityById(pId);
    }

    //修改宣传阵地活动信息
    @ResponseBody
    @RequestMapping("/updateActivityById")
    public ToJson<PropagatePosition> updateActivityById(PropagatePosition record, String gridLocation){
        return propagatePositionService.updateActivityById(record,gridLocation);
    }

    //删除活动
    @ResponseBody
    @RequestMapping("/deleteActivityById")
    public ToJson<PropagatePosition> deleteActivityById(Integer pId){
        return propagatePositionService.deleteActivityById(pId);
    }


}
